<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="shortcut icon" href="imgs/favicon.ico">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
    <meta name="description" content="">
    <meta name="author" content="">
    <title>LOGIN</title>
    <link rel="stylesheet" href="/css/login/bootstrap.min.css">
    <link rel="stylesheet" href="/css/login/register.css">
</head>
<body>
<div class="registerBg">
    <!---container-->
    <div class="container">
        <div class="photograph">
            <span><img src="/imgs/login/photograph.png" alt="个人头像" class="photographImg"></span>
        </div>
        <div class="input-group">
            <span class="input-group-addon"><img alt="登录" src="/imgs/login/account.png"></span>
            <input type="text" id="userName" name="userName" value="18766079215" class="form-control" placeholder="注册邮箱">
        </div>
        <div class="input-group">
            <span class="input-group-addon"><img  alt="密码" src="/imgs/login/password.png"></span>
            <input type="text"  id="password" name="password" value="123456" class="form-control" placeholder="密码输入">
        </div>
        <div class="input-group">
        <button type="button" onclick="login()"  class="btn btn-default btn-block input-group-addon">登录</button>
        </div>
        <div class="input-group">
            <span id="errorMsg" name="errorMsg" style="color: blue;font-size: 18px;"></span>
        </div>
        <div class="onceWord">
            <a href="registerIndex"><span class="once">立即注册</span></a>
            <a href="pswreminderIndex"><span class="forget">忘记密码？</span></a>
        </div>
    </div>
</div>
<script type='text/javascript' src='${ctx.getContextPath()}/js/jquery-2.0.3.min.js'></script>
<script>
    function login(){
       var userName= $("#userName").val();
        var password= $("#password").val();
       if(userName == "" || password == ""){
            $("#errorMsg").text("账号信息不能为空！");
            return false;
        }else{
            $("#errorMsg").text("开始登陆.....");
            $.ajax(
                {
                    type: "POST",//方法类型
                    dataType: "json",
                    url: "/login",
                    data: {
                        userName : userName,
                        password : password
                    },
                    success: function (result) {
                        if (result.code == 200) {
                            $("#errorMsg").text("登陆成功");
                            location.href="home/index";
                        }else{
                            var msg=result.message;
                            $("#errorMsg").text("ERROR："+msg);
                        };
                    },
                    error : function() {
                        alert("系统异常！");
                    }
                }
            );
        }
    }
</script>
</body>
</html>
